package com.rd.student.jiaji.class3.zhangshixuan.Day0808;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;

    public class Demo {
        public static void main(String[] args) throws IOException {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入球员姓名 ：");
            String playerName = sc.nextLine();
            //读取player.txt中的数据
            BufferedReader br = new BufferedReader(new FileReader("Player.txt"));
            String len ;
            //判断是否读到最后一行
            while ((len = br.readLine()) != null) {
                String[] Arr = len.split("，");
                String player = Arr[0];
                String team = Arr[1];
                //判断球员是否存在
                if (playerName.equals(player)) {
                    System.out.println(player + "所属球队为:" + team);
                    br.close();
                    return;
                }
            }
            //不存在
            System.out.println("未找到对应的球员,请重新输入！！！！");
            br.close();
        }
    }

